package com.wj.facedetect.broadcastreceiver;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.wj.facedetect.activity.base.MainActivity;
import com.wj.facedetect.commom.FaceDetectApplication;
import com.wj.facedetect.util.NotificationUtils;

/**
 * Created by wujing on 2018/4/12.
 */

public class IMPushBroadcastReceiver extends BroadcastReceiver {
    public static final String TAG = IMPushBroadcastReceiver.class.getName();

    @Override
    public void onReceive(Context context, Intent intent) {
        showImNotifiction(context);

    }

    public static void showImNotifiction(Context context) {
        Intent intent = new Intent(context, MainActivity.class);//将要跳转的界面
        intent.putExtra("tag", "IM");
        String content = "";
        //利用PendingIntent来包装我们的intent对象,使其延迟跳转
        PendingIntent intentPend = PendingIntent.getActivity(context, Integer.valueOf(FaceDetectApplication.getApplication().getRequestIndex() + ""), intent, PendingIntent.FLAG_CANCEL_CURRENT);
        new NotificationUtils(context).sendNotification("你有一条新消息", content, intentPend);
    }

}

